package com.zzgele.qmzb.api.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.zzgele.qmzb.api.core.AbstractService;
import com.zzgele.qmzb.api.dao.FansMapper;
import com.zzgele.qmzb.api.model.Fans;
import com.zzgele.qmzb.api.service.FansService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Condition;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by Martin on 2017/07/14.
 */
@Service(interfaceClass = FansService.class,proxy="jdk")
@Component
@Transactional
public class FansServiceImpl extends AbstractService<Fans> implements FansService {
    @Resource
    private FansMapper fansMapper;
    public List<HashMap> contributionRoomList(Map<String, Object> map){
        return fansMapper.contributionRoomList(map);
    }

    @Override
    public List<Fans> findByConditions(Long anchor_uid, Long login_uid) {
        Condition condition = new Condition(Fans.class);
        condition.createCriteria().andCondition("uid=" + anchor_uid + " AND fans_uid=" + login_uid);
        return fansMapper.selectByCondition(condition);
    }

    @Override
    public int deleteByConditions(Long anchor_uid, Long login_uid) {
        Condition condition = new Condition(Fans.class);
        condition.createCriteria().andCondition("uid=" + anchor_uid + " AND fans_uid=" + login_uid);
        return fansMapper.deleteByCondition(condition);
    }


}
